package com.wzcl.app.model.vo;

import com.wzcl.app.dao.model.Topic;
import com.wzcl.app.model.common.WZCL;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.springframework.beans.BeanUtils;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

@Data
public class TopicVo extends BaseVo{

    @ApiModelProperty(value = "知识点")
    private List<KnowledgePointVo> knowledgePointList;

    @ApiModelProperty(value = "题目类型")
    private Integer type;
    private String typeStr;

    @ApiModelProperty(value = "难度")
    private Integer hard;
    private String hardStr;

    @ApiModelProperty(value = "描述")
    private String description;

    @ApiModelProperty(value = "题目材料")
    private String  master;

    @ApiModelProperty(value = "总分值")
    private Integer score;

    @ApiModelProperty(value = "详情")
    private List<TopicInfoVo> topicInfoList;

    private TopicVo(){

    }

    public static TopicVo create(Topic topic){
        TopicVo topicVo = new TopicVo();
        BeanUtils.copyProperties(topic,topicVo,"knowledgePointList","topicInfoList");
        if(topic.getTopicInfoList() != null && topic.getTopicInfoList().size()>0){
            topicVo.topicInfoList =  topic.getTopicInfoList().stream().map(TopicInfoVo::create).collect(Collectors.toList());
        }
        topicVo.translationValueStr();
        return topicVo;
    }

    @Override
    public void translationValueStr() {
        Map<String, Map<Integer, String>> map = getTranslationMap();
        this.typeStr = map.get(WZCL.GROUP_NAME.TOPIC_TYPE).get(this.type);
        this.hardStr = map.get(WZCL.GROUP_NAME.HARD_LEVEL).get(this.hard);
    }

    @Override
    public void processResources() {

    }
}
